import {  useRoutes,Navigate } from "react-router-dom";

// import Home from "@/pages/Home/Home";

// import Login from "@/pages/Login/Login";
import LazyLoad from "@/hooks/LazyLoad";
import React from "react"; 

function Ad({children}){
    const token=localStorage.getItem('token')
    return token?children:<Navigate to='/login' />
}
const router=[
    {
        path:'/',
        element:<Navigate to='/login' />,
        meta:{title:'登录'}
    },
    {
        path:'/login',
        element:LazyLoad(React.lazy(()=>import('@/pages/Login/Login'))),
        meta:{title:'登录'}
    },
    {
        path:'/home',
        element:LazyLoad(React.lazy(()=>import("@/pages/Home/Home"))),
        meta:{title:'首页'}
    },
    {
        path:'/detail',
        element:LazyLoad(React.lazy(()=>import("@/pages/Detail/Detail"))),
        meta:{title:'详情'}
    }
]

const Router=()=>{
    const routes=useRoutes(router)
    return routes
}

export default Router